/*
	File:		Player.h
	Author:		Ben Feldmann
	Purpose:	Class for managing game player
*/

#pragma once


#include "Entity.h"
#include "Animation.h"
#include "AnimationSystem.h"
#include "IListener.h"
#include "Emitter.h"
#include "EmitterManager.h"


class MeleeWeapon;
class RangedWeapon;


enum Skills {CAMO = 1, CLOCK, SHIELD};



class Player : public Entity, public IListener
{
private:
	float health;
	float maxHealth;
	float energy;
	float maxEnergy;
	int curWeapon;
	float moveSpeed;
	MeleeWeapon* weapon1;
	RangedWeapon* weapon2;
	int scrapMetal;
	int circuitry;

	float prevX;
	float prevY;
	bool collided;
	Animation* player;
	//int playerID;
	Animation moveAnimation[4];
	Animation idleAnimation[4];
	Animation deathAnimation[4];

	Emitter* deathEm;
	EmitterManager* em;

	float deathTimer;
	float deathSpan;

	int playerNum;

	// Does the A Button attack or activate
	bool Activate;
	bool isMoving;


	// Variables for Skills
	int skillOne, skillTwo;
	bool s1Active, s2Active;
	bool camo, clock, shield;
	float skillTimer;

	// Particles
	Emitter* camoParticle;
	Emitter* clockParticle;
	Emitter* shieldParticle;

	int roomNum;
	bool canMove;

	int fistID[4];
	int clawID[4];
	int sawID[4];
	int swordID[4];
	int swordSpinID;

	// Weapon Sounds
	int fistAttack;
	int swordAttack1;
	int swordAttack2;
	int swordSpcAttack;
	int sawAttack;
	int clawAttack;
	int clawAttach;
	int throwAttack;

	int laserShot;
	int rocketShot;
	int empShot;
	int flameShot;

	int walking;
	int hurt;
	//int death;
	int fail;
	int useSkill;

	bool stun;
	float stunTime;

public:
	Player();
	~Player();

	bool GetStun() {return stun;}
	void SetStun(bool b) {stun = b;}

	void UseSkill(int skill);
	void Attack();
	void SpecialAttack();

	virtual void Update(float elapsed);
	virtual void Render();
	virtual bool CheckCollision(IEntity* base);

	//int GetCurWeapon() {return curWeapon;}

	Animation* GetAnimation()	{return player;}

	void SetMoveAnimation(int id[4]);

	void SetIdleAnimation(int id[4]);

	void SetDeathAnimation(int id[4]);

	void SetAnimation(Animation* tmp);

	//RECT GetWeaponRect()		{return player.GetActiveRect();}

	RECT GetRect();

	// 1: Melee Weapon - 2: Ranged Weapon
	//void SetHealth(float h)		{health = h;}

	int GetCurWeapon() const	{return curWeapon;}

	void SetMoveSpeed(float speed)	{moveSpeed = speed;}
	float GetMoveSpeed()			{return moveSpeed;}

	void  SetHealth(float h)	{health = h;}
	float GetHealth() const		{return health;}

	float GetEnergy() const		{return energy;}
	float GetMaxEnergy() const	{return maxEnergy;}

	void SetEnergy(float e)		{energy = e;}

	float GetMaxHealth() const	{return maxHealth;}
	void SetMaxHealth(float mh)	{maxHealth = mh;}
	void SetMaxEnergy(float me) {maxEnergy = me;}

	int GetMetal() const		{return scrapMetal;}
	int GetCircuitry() const	{return circuitry;}

	void SetMetal(int m)		{scrapMetal = m;}
	void SetCircuitry(int c)	{circuitry = c;}

	bool GetCamo() const		{return camo;}
	bool GetClock() const		{return clock;}
	bool GetShield() const		{return shield;}

	int GetSkillOne() const		{return skillOne;}
	int GetSkillTwo() const		{return skillTwo;}

	int GetPlayerNum() const	{return playerNum;}
	void SetPlayerNum(int num)	{playerNum = num;}

	int GetMeleeWeaponType();
	int GetRangedWeaponType();
	void TakeDam(float num)
	{
		if(shield == false)
			health -= num;
		else
			energy -= num;

		PlaySound(1, false);

		if(health <= 1)
			health = 1;
	}

	MeleeWeapon* GetMelee() const	{return weapon1;}
	RangedWeapon* GetRanged() const	{return weapon2;}

	void SetMelee(MeleeWeapon* mw)		{weapon1 = mw;}
	void SetRanged(RangedWeapon* rw)	{weapon2 = rw;}

	virtual void HandleEvent(Event* thisEvent);

	// Get or set whether the player is near an activatable entity
	inline void CanActivate(bool isNear) { Activate = isNear; }
	inline bool CanActivate(void)		{ return Activate; }


	// Skills
	void SetSkillOne(int s1)	{skillOne = s1;}
	void SetSkillTwo(int s2)	{skillTwo = s2;}

	int GetRoomNum(void) {return roomNum;}
	void SetRoomNum(int num) {roomNum = num;}

	void SetEquipment(int melee, int ranged, int sk1, int sk2, int items[10]);

	void SetCanMove(bool tmp)	{canMove = tmp;}

	int purchased[10];

	void PlaySound(int weapon, bool isWeapon = true);
	void PlaySpcSound(int weapon);

	int GetSawSound() const		{return sawAttack;}
	int GetClawSound() const	{return clawAttach;}
	int GetWalkSound() const	{return walking;}
};
